//
// SlideBar.cs
//
// Copyright (C) 2008 Lukas Lipka <lukaslipka@gmail.com>
//

using System;
using System.Collections.Generic;

using Gtk;

using Dashboard.Util;

namespace Dashboard.Mint.Widgets {

	public class SlideBar : HBox {

		private string[] hello = new string[] { 
			"Hi", "Bonjour", "Guten Tag", "Aloha", "Buon giorno", "Zdravstvuite", "Nazdar",
			"Goeie dag", "Góðan daginn", "God dag", "Jó napot", "Päivää", "Konnichi wa"
		};

		private string[] language = new string[] {
			"English", "French", "German", "Hawaiian", "Italian", "Russian", "Czech",
			"Afrikaans", "Icelandic", "Swedish", "Hungarian", "Finnish", "Japanese"
		};

		public SlideBar ()
		{
			base.AppPaintable = true;
			base.BorderWidth = 5;

			// [ Someone tell that guy next to me to fucking shut up! ]
			int lucky = new Random ().Next (hello.Length);

			VBox vbox = new VBox (false, 5);

			Label label = new Label ();
			label.Markup = String.Format ("<big>{0} <b>{1}</b></big>!", hello [lucky], Environment.UserName);
			label.Xalign = 0.0f;
			vbox.PackStart (label, false, true, 0);

			label = new Label ();
			label.Markup = String.Format ("<i>Now you know how to say 'Hello' in {0}...</i>", language [lucky]);
			label.Xalign = 0.0f;
			vbox.PackStart (label, false, true, 0);

			Add (vbox);
		}

		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			if (!IsDrawable)
				return true;

			Cairo.Context gr = Gdk.CairoHelper.Create (evnt.Window);

			Cairo.Color selection_color = CairoFu.GdkColorToCairoColor (Style.Backgrounds [(int)Gtk.StateType.Normal]);

			Cairo.Color selection_stroke = CairoFu.ColorShade (selection_color, 0.85);
			Cairo.Color selection_fill_light = CairoFu.ColorShade (selection_color, 1.1);
			Cairo.Color selection_fill_dark = CairoFu.ColorShade (selection_color, 0.90);
			selection_stroke.A = selection_fill_light.A = selection_fill_dark.A = 1.0;
			
			Cairo.LinearGradient pattern = new Cairo.LinearGradient (Allocation.X, Allocation.Y, Allocation.X, Allocation.Y + Allocation.Height);
			pattern.AddColorStop (0, selection_fill_light);
			pattern.AddColorStop (1, selection_fill_dark);
			
			gr.Pattern = pattern;
			gr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
			gr.Fill ();

			CairoFu.DisposeContext (gr);
			
			return base.OnExposeEvent (evnt);
		}
	}
}
